package com.caxxb.dao.impl;

import com.caxxb.dao.LogDao;
import com.caxxb.entity.Log;
import com.caxxb.util.DBUtil;
import com.caxxb.util.PageData;

import java.time.LocalDateTime;

public class LogDaoImpl implements LogDao {
    @Override
    public boolean recordLog(int userid,String ip,  LocalDateTime time) {
        String sql="insert into log values(null,?,?,?)";
        int result = DBUtil.exUpdate(sql, userid, ip, time);
        return result >0;
    }

    @Override
    public PageData<Log> getNumByPage(String num, int pageNo, int pageSize) {
        String sql = "SELECT log.logid, log.userid, log.ipaddr, log.logintime, `user`.account_number FROM log INNER JOIN `user` ON log.userid = `user`.user_id where `user`.account_number like ? ";
        PageData<Log> pageData = DBUtil.exQueryByPage(sql, Log.class, pageNo,pageSize,num);
        return pageData;
    }
}
